﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class clients : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Form.DefaultButton = btSearch.UniqueID;
    }

    protected void btSearch_Click(object sender, EventArgs e)
    {
        dsClient.Where = "Name.Contains(@Search) || Number.Contains(@Search)";
        dsClient.WhereParameters.Add(new Parameter("Search", DbType.String, tbSearch.Text));
        gvClient.DataBind();
        tbSearch.Text = "";
        gvClient.SelectedIndex = 0;
    }

    protected void btClearSearch_Click(object sender, EventArgs e)
    {
        dsClient.Where = "";
        dsClient.WhereParameters.Clear();
        tbSearch.Text = "";
        gvClient.DataBind();
    }

    protected void gvClient_DataBinding(object sender, EventArgs e)
    {
        if (User.IsInRole("Administrator"))
            gvClient.Columns[gvClient.Columns.Count-1].Visible = true;
        else
            gvClient.Columns[gvClient.Columns.Count-1].Visible = false;
    }
}
